<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // fn 专门用于创建对象  fn叫做工厂函数
        function fn() {
            let obj = new Object;
            obj.name = "旺财";
            obj.say = function () {
                console.log('汪汪');
            }
            return obj
        }
        let a = fn();
        let b = fn();
        console.log(a, b, a == b);

        // 工厂函数传递参数控制对象不一致
        function createObj(name) {
            let obj = new Object;
            obj.name = name;
            obj.say = function () {
                console.log(this.name + '汪汪')
            }
            return obj
        }
        let c = createObj('来福');
        c.say();
    </script>
</body>

</html>